//验证输入的内容是否已存在
var express = require('express');
var router = express.Router();
var sqlQuery = require('../../../module/sql');


//添加用户时验证用户名是否已存在
router.post('/testing',async(req,res)=>{
    //判断用户名是否存在
    let username = req.body.username
    let sqlStr = "select * from user where username = ?"
    let result = await sqlQuery(sqlStr,[username])
    if(result.length == 0){
        res.json({
            state:"ok",
            content:"没有此用户名，可以添加"
        })
    }else{
        res.json({
            state:"fail",
            content:"用户名已存在"
        })
    }
})

module.exports = router